package com.pj.main;

import java.io.IOException;

public class ExecuteExe {
    public static void main(String[] args) {
        try {
            String pathToExe = "D:\\VMware FANUC NCGUIDE\\Fanuc通信测试程序丨233\\Fanuc.exe"; // 替换为你的.exe文件的路径
            Process process = Runtime.getRuntime().exec(pathToExe);

            // 等待进程结束
            int exitCode = process.waitFor();
            System.out.println(process + ".exe文件已启动,退出码为: " + exitCode);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (RuntimeException e) {
            System.err.println("执行 Fanuc.exe 时发生了异常: " + e.getMessage());
            e.printStackTrace();
        }

        // 等待用户输入
        System.out.println("按回车键退出...");
        try {
            System.in.read();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}